class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-09-16",
      revision: "723d6685ec889bb59b0704113686c66f5addecf8"
  version "2021-09-16"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "8ebc58bbd86e6858c75ec46646600641d3a331063278713adeed2f5f2b809e39"
    sha256 cellar: :any_skip_relocation, big_sur:       "ddb39a0977e646a368565e7e70edc32e9a1f4bb384a785c0644560f00e348d9a"
    sha256 cellar: :any_skip_relocation, catalina:      "560fb338ffaa04916d0ce271b32d94cc83ba3eac8afa647ab175d429133720c9"
    sha256 cellar: :any_skip_relocation, mojave:        "0ab2358cc751e44e2f592e19105ff8162ed006a5b8bbc0e3365f9e8c16dd3362"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "356f3788229671f7515be36af45cad61017fce058190713388a72ab8cdde7763"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
